.root {
  --ai-size-xs: 18px;
  --ai-size-sm: 22px;
  --ai-size-md: 28px;
  --ai-size-lg: 34px;
  --ai-size-xl: 44px;

  --ai-size-input-xs: 30px;
  --ai-size-input-sm: 36px;
  --ai-size-input-md: 42px;
  --ai-size-input-lg: 50px;
  --ai-size-input-xl: 60px;

  --ai-size: var(--ai-size-md);
  --ai-color: var(--mantine-color-white);

  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  user-select: none;
  overflow: hidden;

  width: var(--ai-size);
  height: var(--ai-size);
  min-width: var(--ai-size);
  min-height: var(--ai-size);
  border-radius: var(--ai-radius, var(--mantine-radius-default));
  background: var(--ai-bg, var(--mantine-primary-color-filled));
  color: var(--ai-color, var(--mantine-color-white));
  border: var(--ai-bd, rem(1px) solid transparent);
  cursor: pointer;

  @mixin hover {
    &:where(:not([data-loading], :disabled, [data-disabled])) {
      background-color: var(--ai-hover, var(--mantine-primary-color-filled-hover));
      color: var(--ai-hover-color, var(--ai-color));
    }
  }

  &[data-loading] {
    cursor: not-allowed;

    & .icon {
      opacity: 0;
      transform: translateY(100%);
    }
  }

  &:where(:disabled:not([data-loading]), [data-disabled]:not([data-loading])) {
    cursor: not-allowed;
    border: 1px solid transparent;
    color: var(--mantine-color-disabled-color);
    background: var(--mantine-color-disabled);

    &:active {
      transform: none;
    }
  }
}

.loader {
  inset: -1px;
  position: absolute;
  border-radius: var(--ai-radius, var(--mantine-radius-default));
  display: flex;
  align-items: center;
  justify-content: center;

  @mixin where-light {
    background-color: rgba(255, 255, 255, 0.15);
  }

  @mixin where-dark {
    background-color: rgba(0, 0, 0, 0.15);
  }
}

.group {
  --ai-border-width: 1px;
  display: flex;

  & :where(*) {
    &:focus {
      position: relative;
      z-index: 1;
    }
  }

  &[data-orientation='horizontal'] {
    flex-direction: row;

    & .root,
    & .groupSection {
      &:not(:only-child):first-child {
        border-end-end-radius: 0;
        border-start-end-radius: 0;
        border-inline-end-width: calc(var(--ai-border-width) / 2);
      }

      &:not(:only-child):last-child {
        border-end-start-radius: 0;
        border-start-start-radius: 0;
        border-inline-start-width: calc(var(--ai-border-width) / 2);
      }

      &:not(:only-child):not(:first-child):not(:last-child) {
        border-radius: 0;
        border-inline-width: calc(var(--ai-border-width) / 2);
      }
    }
  }

  &[data-orientation='vertical'] {
    flex-direction: column;

    & .root,
    & .groupSection {
      &:not(:only-child):first-child {
        border-end-start-radius: 0;
        border-end-end-radius: 0;
        border-bottom-width: calc(var(--ai-border-width) / 2);
      }

      &:not(:only-child):last-child {
        border-start-start-radius: 0;
        border-start-end-radius: 0;
        border-top-width: calc(var(--ai-border-width) / 2);
      }

      &:not(:only-child):not(:first-child):not(:last-child) {
        border-radius: 0;
        border-bottom-width: calc(var(--ai-border-width) / 2);
        border-top-width: calc(var(--ai-border-width) / 2);
      }
    }
  }
}

.icon {
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    transform 150ms ease,
    opacity 100ms ease;
  width: 100%;
  height: 100%;
}

.groupSection {
  --section-height-xs: 18px;
  --section-height-sm: 22px;
  --section-height-md: 28px;
  --section-height-lg: 34px;
  --section-height-xl: 44px;

  --section-height-input-xs: 30px;
  --section-height-input-sm: 36px;
  --section-height-input-md: 42px;
  --section-height-input-lg: 50px;
  --section-height-input-xl: 60px;

  --section-padding-x-xs: 6px;
  --section-padding-x-sm: 8px;
  --section-padding-x-md: 10px;
  --section-padding-x-lg: 12px;
  --section-padding-x-xl: 16px;

  --section-height: var(--section-height-sm);
  --section-padding-x: var(--section-padding-x-sm);
  --section-color: var(--mantine-color-white);

  font-weight: 600;
  width: auto;
  border-radius: var(--section-radius, var(--mantine-radius-default));
  font-size: var(--section-fz, var(--mantine-font-size-sm));
  background: var(--section-bg, var(--mantine-primary-color-filled));
  border: var(--section-bd, rem(1px) solid transparent);
  color: var(--section-color, var(--mantine-color-white));
  height: var(--section-height, var(--section-height-sm));
  padding-inline: var(--section-padding-x, var(--section-padding-x-sm));
  vertical-align: middle;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
